home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / BASE_BNN.C < prev    next >
C/C++ Source or Header  |  1992-08-20  |  3KB  |  59 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // Created: MBN 07/18/89 -- Initial design and implementation
  13. // Updated: VDN 02/21/92 -- New lite version
  14. // Updated: JAM 08/19/92 -- modernized template syntax, remove macro hacks
  15. //                          non-template classes CoolBinary_Node=>CoolBase_Binary_Node
  16. //
  17. // The CoolBase_Binary_Node class implements  nodes for binary trees  that have  no data
  18. // slot.  This node class contains left and right subtree pointers.   Since the
  19. // CoolBase_Binary_Node   class is  intended   for the  sole   use of  the parameterized
  20. // CoolBinary_Node<Type> class, all constructors and  methods are protected and the
  21. // CoolBinary_Tree class is declared as a friend class.
  22. //
  23. // The private data section contains two  pointers to CoolBase_Binary_Node  objects, one
  24. // for the left subtree and one for the right subtree.  There are two protected
  25. // constructors  for the class.   The first takes  no arguments and initializes
  26. // the two pointers to  NULL.     The  second takes   a  reference  to  another
  27. // CoolBase_Binary_Node object and duplicates its values.
  28. //
  29. // Methods are provided to determine if a node  is a  leaf or  the root of some
  30. // subtree and implement member-wise assignment from one CoolBase_Binary_Node to another
  31. // via the overloaded operator=.
  32. //
  33.  
  34. #ifndef BASE_BINARY_NODEH            // If no definition for class
  35. #include <cool/Base_Binary_Node.h>        // include header file
  36. #endif    
  37.  
  38. // CoolBase_Binary_Node -- Simple constructor to initialize a node object
  39. // Input:         None
  40. // Output:        None
  41.  
  42. CoolBase_Binary_Node::CoolBase_Binary_Node () {
  43.   this->ltree = NULL;                // Initialize left subtree
  44.   this->rtree = NULL;                // Initialize right subtree
  45.   this->avl_balance = 0;            // Initialize avl balance
  46. }
  47.  
  48. // ~CoolBase_Binary_Node -- Destructor has to be virtual so that 
  49. //                     ~CoolBase_Binary_Node<Type> is called on ltree and rtree.
  50. // Input:          None
  51. // Output:         None
  52.  
  53. CoolBase_Binary_Node::~CoolBase_Binary_Node () {
  54.   delete this->ltree;                // Delete left subtree, virtual
  55.   delete this->rtree;                // Delete right subtree
  56. }
  57.  
  58.  
  59.